import { addNameSpace } from './util'

const NAME_SPACE = 'INDIVIDUATION_SETTING'

const addPrefix = addNameSpace(NAME_SPACE)

// 获取数据
export const GET_DATA = addPrefix('GET_DATA')

// 获取数据成功
export const GET_DATA_SUCCESS = addPrefix('GET_DATA_SUCCESS')

// 获取数据失败
export const GET_DATA_FAIL = addPrefix('GET_DATA_FAIL')

// 设置IP
export const SET_IP = addPrefix('SET_IP')

// 设置上行推送地址
export const SET_RECEIVE_URL = addPrefix('SET_RECEIVE_URL')

// 设置余额提醒号码
export const SET_REMIND_PHONE = addPrefix('SET_REMIND_PHONE')

// 设置余额提醒金额
export const SET_REMIND_VALUE = addPrefix('SET_REMIND_VALUE')

// 更新数据
export const UPDATE_DATA = addPrefix('UPDATE_DATA')

// 更新数据成功
export const UPDATE_DATA_SUCCESS = addPrefix('UPDATE_DATA_SUCCESS')

// 更新数据失败
export const UPDATE_DATA_FAIL = addPrefix('UPDATE_DATA_FAIL')

export const getData = () => ({ type: GET_DATA })

export const getDataSuccess = (data) => ({ type: GET_DATA_SUCCESS, data })

export const getDataFail = () => ({ type: GET_DATA_FAIL })

export const setIp = (ip) => ({ type: SET_IP, ip })

export const setReceiveUrl = (receiveUrl) => ({ type: SET_RECEIVE_URL, receiveUrl })

export const setRemindPhone = (remindPhone) => ({ type: SET_REMIND_PHONE, remindPhone })

export const setRemindValue = (remindValue) => ({ type: SET_REMIND_VALUE, remindValue })

export const updateData = () => ({ type: UPDATE_DATA })

export const updateDataSuccess = () => ({ type: UPDATE_DATA_SUCCESS })

export const updateDataFail = () => ({ type: UPDATE_DATA_FAIL })

export default {
  getData,
  getDataSuccess,
  getDataFail,
  setIp,
  setReceiveUrl,
  setRemindPhone,
  setRemindValue,
  updateData,
  updateDataSuccess,
  updateDataFail,
}